/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2019-02-13 Time: 23:07
 */
import {DispatchOrder,CompleteOrder,DeleteOrder,ContinueOrder} from "./Actions"
import {FetchStatus} from "../../configuration/RequestConfiguration";


//工单改变状态
export const onChangeOrder = (state = {}, action)=>{
    switch (action.type) {
        case DispatchOrder: {//挂起
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
        case CompleteOrder: {//完成
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
        case DeleteOrder: {//删除
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
        case ContinueOrder: {//继续处理
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};
